/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package gek.uni.diplom.ecore.stack.Stack.impl;

import gek.uni.diplom.ecore.stack.Stack.Element;
import gek.uni.diplom.ecore.stack.Stack.Stack;
import gek.uni.diplom.ecore.stack.Stack.StackPackage;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Stack</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link gek.uni.diplom.ecore.stack.Stack.impl.StackImpl#getSize <em>Size</em>}</li>
 *   <li>{@link gek.uni.diplom.ecore.stack.Stack.impl.StackImpl#getChildren <em>Children</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class StackImpl extends EObjectImpl implements Stack {
	/**
   * The default value of the '{@link #getSize() <em>Size</em>}' attribute.
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @see #getSize()
   * @generated
   * @ordered
   */
	protected static final long SIZE_EDEFAULT = 0L;

	/**
   * The cached value of the '{@link #getSize() <em>Size</em>}' attribute.
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @see #getSize()
   * @generated
   * @ordered
   */
	protected long size = SIZE_EDEFAULT;

	/**
   * This is true if the Size attribute has been set.
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   * @ordered
   */
	protected boolean sizeESet;

	/**
   * The cached value of the '{@link #getChildren() <em>Children</em>}' reference list.
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @see #getChildren()
   * @generated
   * @ordered
   */
	protected EList<Element> children;

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	protected StackImpl() {
    super();
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	@Override
	protected EClass eStaticClass() {
    return StackPackage.Literals.STACK;
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	public EList<Element> getChildren() {
    if (children == null) {
      children = new EObjectResolvingEList<Element>(Element.class, this, StackPackage.STACK__CHILDREN);
    }
    return children;
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	public void push(Element element) {
    // TODO: implement this method
    // Ensure that you remove @generated or mark it @generated NOT
    throw new UnsupportedOperationException();
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	public long getSize() {
    return size;
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	public void setSize(long newSize) {
    long oldSize = size;
    size = newSize;
    boolean oldSizeESet = sizeESet;
    sizeESet = true;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, StackPackage.STACK__SIZE, oldSize, size, !oldSizeESet));
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	public void unsetSize() {
    long oldSize = size;
    boolean oldSizeESet = sizeESet;
    size = SIZE_EDEFAULT;
    sizeESet = false;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.UNSET, StackPackage.STACK__SIZE, oldSize, SIZE_EDEFAULT, oldSizeESet));
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	public boolean isSetSize() {
    return sizeESet;
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	public Element pop() {
    // TODO: implement this method
    // Ensure that you remove @generated or mark it @generated NOT
    throw new UnsupportedOperationException();
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
    switch (featureID) {
      case StackPackage.STACK__SIZE:
        return getSize();
      case StackPackage.STACK__CHILDREN:
        return getChildren();
    }
    return super.eGet(featureID, resolve, coreType);
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
    switch (featureID) {
      case StackPackage.STACK__SIZE:
        setSize((Long)newValue);
        return;
      case StackPackage.STACK__CHILDREN:
        getChildren().clear();
        getChildren().addAll((Collection<? extends Element>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	@Override
	public void eUnset(int featureID) {
    switch (featureID) {
      case StackPackage.STACK__SIZE:
        unsetSize();
        return;
      case StackPackage.STACK__CHILDREN:
        getChildren().clear();
        return;
    }
    super.eUnset(featureID);
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	@Override
	public boolean eIsSet(int featureID) {
    switch (featureID) {
      case StackPackage.STACK__SIZE:
        return isSetSize();
      case StackPackage.STACK__CHILDREN:
        return children != null && !children.isEmpty();
    }
    return super.eIsSet(featureID);
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	@Override
	public String toString() {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (size: ");
    if (sizeESet) result.append(size); else result.append("<unset>");
    result.append(')');
    return result.toString();
  }

} //StackImpl
